<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePolicyTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('policy', function (Blueprint $table) {
            $table->increments('id');
            $table->integer("admin_id")->comment('管理员ID');
            $table->integer("booking_id")->comment("票台ID");
            $table->integer("type")->comment("政策类型：1=特殊政策，2=运价直连");
            $table->integer('source_id')->comment('数据源');
            $table->integer('source_type')->comment('数据源产品类型');
            $table->string("airline",512)->comment('航司');
            $table->string("depart")->nullable()->comment("出发机场");
            $table->string("arrive")->nullable()->comment("到达机场");
            $table->date("depart_at")->comment("起飞日期");
            $table->date("depart_end")->comment("到达日期");
            $table->date("rule_at")->comment("规则开启日期");
            $table->date("rule_end")->comment("规则结束日期");
            $table->text("flight_lines")->nullable()->comment("使用航线");
            $table->text("flights")->nullable()->comment("使用航班");
            $table->string("cabins")->nullable()->comment("使用舱位");
            $table->integer("last_sale")->nullable()->comment("最晚出售限制（天）");
            $table->integer("begin_sale")->nullable()->comment("最早出售限制（天）");
            $table->integer("last_sale_minute")->nullable()->comment("起飞前禁售时间（分钟）");
            $table->string("time_enable")->nullable()->comment('起飞时间限制');
            $table->string("week_enable")->nullable()->comment('班期限制');
            $table->tinyInteger("share")->default(0)->comment('是否共享：1=是，0=否');
            $table->decimal("add_price")->default(0)->comment('票面加价');
            $table->tinyInteger("percentage_price")->default(0)->comment('票面加价百分比');
            $table->tinyInteger("refund")->default(1)->comment("退票计算基准：1=票面价，2=标准价，3=FD价");
            $table->integer("seat_min")->default(1)->comment("推送最小座位数");
            $table->tinyInteger("fix")->default(1)->comment("是否定额：1=见舱，2=定额");
            $table->integer("product_type")->default(1)->comment("产品类型：1=包机，2=切位");
            $table->string("office")->nullable()->comment("office");
            $table->tinyInteger("come_up_type")->default(1)->comment("上浮类型：1=绝对值，2=比例");
            $table->tinyInteger("come_up_value")->default(0)->comment("上浮值");
            $table->tinyInteger("filter_nervous")->default(0)->comment('是否紧张过滤：1=否，1=是');
            $table->tinyInteger("nervous_value")->default(0)->comment('紧张过滤阈值');
            $table->string("iata",20)->nullable()->comment('IATA');
            $table->string("policy_code")->comment('政策代码');
            $table->tinyInteger('status')->default(1)->comment('状态：1=正常，2=禁用');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('policy');
    }
}
